<div class="panel panel-default panel-intro" style="margin-bottom: 20px">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent2" class="tab-content">
            <div class="tab-pane fade active in" id="three">
                <div class="widget-body no-padding">
                    <form id="find-form" class="form-horizontal" method="POST" action="" multiple="true">
                        <a data-url="product_lists/products?status=radio&action=1" href="#"  class="btn btn-success btn-ajaxss pull-left search"  data-title="选择产品" id="choose_product" style="margin-right: 10px">{if $product_name}{$product_name}{else/}选择产品{/if}</a>
                        <input type="hidden" id="product" name="temp[0][bn]" value="{$bn}">
                        <input type="hidden" id="product_name" name="temp[0][name]" value="{$product_name}">
                        <div class="pull-left search" style="margin-right: 10px"><input class="form-control" type="number" name="temp[0][num]" value="{$num}" placeholder="生产数量"></div>
                        <div class="pull-left search">
                            <button type="submit" class="btn btn-success">{:__('OK')}</button>
                            <!--<button type="reset" id="btn" class="btn btn-default btn-embossed">{:__('Reset')}</button>-->
                        </div>
                        <input name="search" type="hidden" value="1">
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
<div class="panel panel-default panel-intro">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%">
                        <thead>
                        <tr>
                            <th>半成品编号</th>
                            <th>半成品名称</th>
                            <th>半成品规格</th>
                            <th>单位</th>
                            <th>需求数量</th>
                            <th>当前库存</th>
                        </tr>
                        </thead>
                        <tbody id="MyPublishShow">
                        {volist name="part_pro" id="vo"  }
                        <tr>
                            <td>{$vo.bn}</td>
                            <td>{$vo.name}</td>
                            <td>{$vo.spec}</td>
                            <td>{$vo.unit}</td>
                            <td>{$vo.Dosage}</td>
                            <td>{$vo.num}</td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<div class="panel panel-default panel-intro" style="margin-top: 20px">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent1" class="tab-content">
            <div class="tab-pane fade active in" id="two">
                <div class="widget-body no-padding">
                    <table id="table1" class="table table-striped table-bordered table-hover table-nowrap" width="100%">
                        <thead>
                        <tr>
                            <th>原材料编号</th>
                            <th>原材料名称</th>
                            <th>原材料规格</th>
                            <th>单位</th>
                            <th>需求数量</th>
                            <th>当前库存</th>
                            <th>需采购数量</th>
                        </tr>
                        </thead>
                        <tbody id="MyPublishShow1">
                            {volist name="pro" id="vo"  }
                            <tr>
                                <td>{$vo.bn}</td>
                                <td>{$vo.name}</td>
                                <td>{$vo.spec}</td>
                                <td>{$vo.unit}</td>
                                <td>{$vo.Dosage}</td>
                                <td>{$vo.num}</td>
                                <td>{if $vo.Dosage-$vo.num<0}0{else/}{$vo.Dosage-$vo.num}{/if}</td>
                            </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<script>
    window.onload = function(){
        var btn = document.getElementById("btn");
        var choose_product = document.getElementById("choose_product");
        choose_product.onclick = function(obj){
            var url = $(this).attr('data-url');
            if(!url) return false;
            var msg = $(this).attr('data-title');
            var width = $(this).attr('data-width');
            var height = $(this).attr('data-height');
            var area = [$(window).width() > 800 ? (width?width:'800px') : '95%', $(window).height() > 600 ? (height?height:'600px') : '95%'];
            var options = {
                shadeClose: false,
                shade: [0.3, '#393D49'],
                area: area,
                callback:function(value){
                    if(value){
                        var choose_product = document.getElementById("choose_product");
                        choose_product.innerText = value[0].name;
                        var product = document.getElementById("product");
                        product.value = value[0].bn;
                        var product_name = document.getElementById("product_name");
                        product_name.value = value[0].name;
                    }else{
                        Layer.alert('请选择一个产品');
                    }
                }
            };
            Fast.api.open(url,msg,options);
        }
    };
</script>
